Skip to content

test(cli): cover watch out-file overwrite#11994

Open
nightt5879 wants to merge 3 commits into
swc-project:mainfrom
nightt5879:nightt5879/fix-swc-watch-out-file-duplication
Open

test(cli): cover watch out-file overwrite#11994
nightt5879 wants to merge 3 commits into
swc-project:mainfrom
nightt5879:nightt5879/fix-swc-watch-out-file-duplication

Conversation

@nightt5879

@nightt5879 nightt5879 commented Jul 6, 2026

Copy link
Copy Markdown

Description:

Adds regression coverage for swc compile --watch --out-file, matching the Windows scenario reported in #10524.

The new CLI test starts watch mode with a single output file, waits for the initial output, rewrites the input file, and asserts that the rebuilt output:

  • drops stale content from the first build
  • contains only one console.log
  • is overwritten instead of appended/prepended

This locks in the current rebuild behavior for single-file watch output.

This also bumps two Cargo.lock entries to clear current cargo-deny advisories reported by CI:

  • anyhow from 1.0.100 to 1.0.103
  • crossbeam-epoch from 0.9.18 to 0.9.20

Verified with:

  • cargo test -p swc_cli_impl issue_10524_watch_out_file_overwrites_rebuilt_output -- --nocapture
  • cargo-deny 0.18.9 check
  • manual Windows watch repro using target/debug/swc.exe compile src/app/v1/simple.js --out-file public/v1/output.js --watch; after rewriting the input, output.js contained only console.log("Hello, world 2!!");
  • cargo fmt -p swc_cli_impl --check
  • cargo clippy -p swc_cli_impl --tests -- -D warnings

I also tried broader local checks on Windows:

  • cargo fmt --all --check failed before formatting with os error 206 (path too long)
  • cargo test -p swc_cli_impl -- --nocapture ran the new test successfully, but the full suite has existing Windows failures unrelated to this change, including issue_8265_1/issue_8667_1 using unavailable ls, plus existing path/root-mode/watch-dir failures

BREAKING CHANGE:

None.

Related issue (if exists):

Closes #10524

@CLAassistant

CLAassistant commented Jul 6, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@changeset-bot

changeset-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6c17035

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@nightt5879

Copy link
Copy Markdown
Author

i can't open the:https://cla-assistant.io/swc-project/swc?pullRequest=11994 , i will try it later, and then turn this PR to Open

@codspeed-hq

codspeed-hq Bot commented Jul 6, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 189 untouched benchmarks
⏩ 61 skipped benchmarks1


Comparing nightt5879:nightt5879/fix-swc-watch-out-file-duplication (6c17035) with main (f680df5)

Open in CodSpeed

Footnotes

  1. 61 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@socket-security

socket-security Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​anyhow@​1.0.1038110093100100

View full report

@nightt5879 nightt5879 marked this pull request as ready for review July 7, 2026 08:00
@nightt5879 nightt5879 requested a review from a team as a code owner July 7, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate code when running SWC with --output-file and --watch on WIndows

2 participants